//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.4/xslt/JavaClass.xsl

package com.novix.struts.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.novix.portal.framework.service.IGenericService;
import com.novix.portal.framework.util.IConstants;
import com.novix.portal.framework.util.UserContainer;
import com.novix.struts.form.ViewOrganizationsForm;

/**
 * MyEclipse Struts Creation date: 05-04-2005
 * 
 * XDoclet definition:
 * 
 * @struts:action path="/viewOrganizations" name="viewOrganizationsForm"
 *                input="/form/viewOrganizations.jsp" scope="request"
 *                validate="true"
 * @struts:action-forward name="success" path="/domino/SplashPage"
 *                        redirect="true"
 * @struts:action-forward name="failure" path="/domino/SplashPage"
 *                        redirect="true"
 */
public class ViewOrganizationsAction extends PortalBaseAction {

    // --------------------------------------------------------- Instance
    // Variables

    // --------------------------------------------------------- Methods

    /**
     * Method execute
     * 
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
        if (isCancelled(request))
            return mapping.findForward(IConstants.HOME);
        ViewOrganizationsForm viewOrganizationsForm = (ViewOrganizationsForm) form;
        IGenericService service = getPortalService();
        UserContainer uc = (UserContainer) request.getSession().getAttribute(IConstants.USER_CONTAINER);
        List list = new ArrayList();
        if (request.getSession().getAttribute(IConstants.WEB_ORGANIZATIONS) == null) {
            list = service.getWebOrganizations(uc.getUser());
            request.getSession().setAttribute(IConstants.WEB_ORGANIZATIONS, list);
        } else
            list = (List) request.getSession().getAttribute(IConstants.WEB_ORGANIZATIONS);
        return mapping.findForward(IConstants.SUCCESS);
    }

}